<?php

namespace App\Http\Requests\UserApi;

use App\Http\Requests\BaseRequest;
use Illuminate\Foundation\Http\FormRequest;

class GroupRequest extends BaseRequest
{
    protected $rules = [

    ];

    //这里我只写了部分字段，可以定义全部字段
    protected $strings_key = [
        'group_class_id' => '套餐ID',
        'subscribe_id' => '预约ID',
    ];

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $function = request()->route()->getAction();
        $rules = $this->rules;

        // 根据不同的情况, 添加不同的验证规则
        if ($function['controller'] == 'App\Http\Controllers\UserApi\GroupClassController@group_info')
        {
            $rules=[
                'group_class_id'=>'required|exists:group_class,id',
            ];
        }

        if ($function['controller'] == 'App\Http\Controllers\UserApi\GroupClassController@by_group')
        {
            $rules=[
                'group_class_id'=>'required|exists:group_class,id',
            ];
        }

        if ($function['controller'] == 'App\Http\Controllers\UserApi\GroupClassController@change_camp_subscribe')
        {
            $rules=[
                'subscribe_id'=>'required|exists:user_subscribe,id',
            ];
        }

        return $rules;
    }
}
